<include file="Public:header" />
<div id="zoneHeader">
    <h2>控制台</h2>
</div><!--/#zoneHeader-->
<div id="zoneBody" class="noFooter">
<style type="text/css">
.consoleBox{border:1px solid #ccc;padding:5px;}
.consoleBox dt{border-bottom:1px solid #ccc;font-size:14px;font-weight:bold;}
.consoleBox dd{padding-top:5px;}

#flow24{height:200px;}

#incomeZone, #incomeZone2, #aderMoney, #servers { float:left; overflow:auto; }
#incomeZone .consoleBox, #incomeZone2 .consoleBox, #aderMoney .consoleBox, #servers .consoleBox {float:left;width:330px;margin:0 5px 5px 0;}

#servers .consoleBox { width:480px; }

.costServerRunning { color:red; }

</style>
<div id="qqTalk">
    <span>请输入QQ号：</span><input type="text" name="qq" class="fW150p" /> <button>发起QQ临时会话</button>
</div> <!--/#qqTalk--> 

<script>
(function() {
     var url = 'http://wpa.qq.com/msgrd?v=3&uin={QQ}&site=qq&menu=yes',
        $o = $('#qqTalk');

    $o.find('button').click(function() {
        var $qq = $o.find('[name=qq]'),
            qq = $.trim($qq.val());

        if(qq.length < 5) {
            alert('请输入QQ号');

            return false;
        }

        go(url.replace(/\{QQ\}/, qq));
    });

    function go(url) {
        var form = document.createElement('form'),
            o = document.getElementsByTagName('script')[0];

        form.setAttribute('action', url)
        form.setAttribute('method', 'post')
        form.setAttribute('target', '_blank');
        o.parentNode.appendChild(form);
        form.submit();
    }
})()
</script>

<div id="flow24" hide="3"></div> <!--/#flow24--> 
<div style="clear:both"></div>
<script>
/**
 * 获取计费服务器待计费时间段列表
 */
function getClickStreamIndex(){
    $('div[ip]').each(function(k, v){
        var $o = $(v),
            ip = $o.attr('ip'),
            url = 'http://' + ip + ':89/click/Api/getClickStreamIndex.php?callback=?';

        $.getJSON(url, function(j) {
            var html = '';

            if (!j.s) {
                $o.html('');

                return false;
            }

            $.each(j.d, function(k2, v2) {
                html +=  '<p>' + v2 + '</p>';
            })

            $o.html(html);
        })
    })
}

/**
 * 获取处于运行状态的计费服务器
 */
function getCostServerRunStatus() {
    var url = '?a=getRunningCostServer',
        $o = $('#servers'),
        cls = 'costServerRunning';

    $.getJSON(url, function(j) {
        $o.find('.' + cls).removeClass(cls);

        if (!j.d) {
            return false;
        }

        $o.find('div[ip="' + j.d + '"]').parents('tr').addClass(cls);
    });
}

!function(){
$(function() {
    function run() {
        getCostServerRunStatus();
        getClickStreamIndex();
    }

    run();

    setInterval(run, 10000);
})
}();


</script>
</flag:isadmin>

</div><!--/#zoneBody-->

<flag:isadmin>
<script type="text/javascript">
$(function () {
$.getJSON('/click/Api/getPlanTypeFlowHour.php', function(j) {
    if(!j.s) {
        return false;
    }

    var d = j.d,
        r = [];

    $.each(d, function(k, v) {
        var tmp = {name : k, data : []},
            t2 = 0;

        for(var i=0; i < 24; i++) {
            t2 = typeof(v[i]) == 'undefined' ? 0 : parseInt(v[i], 10);
            tmp.data.push(t2);
        }

        r.push(tmp);
    })

    $('#flow24').highcharts({
            chart: {
                type: 'spline'
            },
            
            title: {
                text: '24小时结算量走势图',
                x: -20 //center
            },
            xAxis: {
                categories: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23]
            },
            yAxis: {
                title: {
                    text: '结算量(次)'
                },
                min : 0,
                plotLines: [{
                    value: 0,
                    width: 1,
                    color: '#808080'
                }]
            },
            tooltip: {
                valueSuffix: '次',
                crosshairs : true,   //显示指针线
                shared: true    //可同时显示多个项目对应的数据
            },
            legend: {
                layout: 'vertical',
                align: 'right',
                verticalAlign: 'middle',
                borderWidth: 0
            },
            series: r
        });

    })
});
</script>
</flag:isadmin>
<script src="__RES_ROOT__/js/chart/highcharts.js"></script>
<include file="Public:footer" />
